﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPageAdmin : System.Web.UI.MasterPage
{
    private Users user;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Admin"] != null)
        {
            this.user = (Users)Session["Admin"];
        }
        else if (Session["Mod"] != null)
        {
            this.user = (Users)Session["Mod"];
        }

        if (user != null)
        {
            this.lblUsername.Text = this.user.Username;
            if (this.user.Role.IdRole == Constant.ROLE_ADMIN)
            {
                this.menuManegeAccount.Visible = true;
                this.menuManegeArticle.Visible = true;
            
            }
            else if(this.user.Role.IdRole == Constant.ROLE_MOD)
            {
                this.menuManegeAccount.Visible = false;
                this.menuManegeArticle.Visible = true;
            
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void lbLogOut_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("Login.aspx");
    }
}